/* --------------------------------------------------------
 * Copyright (c) aeky , Inc.  All rights reserved.
 * --------------------------------------------------------
 */
package com.aeky.client.ui;

import com.smartgwt.client.widgets.layout.HLayout;

/**
 * 
 * @author aeky
 */
public class AekyPortalLayout extends HLayout {

    public AekyPortalLayout() {
        setMembersMargin(6);
        addMember(new AekyPortalColumn("60%"));
        addMember(new AekyPortalColumn("30%"));
    }

    public AekyPortalColumn addPortlet(AekyPortlet portlet) {
        // find the column with the fewest portlets
        int fewestPortlets = Integer.MAX_VALUE;
        AekyPortalColumn fewestPortletsColumn = null;
        for (int i = 0; i < getMembers().length; i++) {
            int numPortlets = ((AekyPortalColumn) getMember(i)).getMembers().length;
            if (numPortlets < fewestPortlets) {
                fewestPortlets = numPortlets;
                fewestPortletsColumn = (AekyPortalColumn) getMember(i);
            }
        }
        fewestPortletsColumn.addMember(portlet);
        return fewestPortletsColumn;
    }
}
